<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__ROOT__/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="__ROOT__/layui/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="num" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">QQ</label>
                            <div class="layui-input-inline">
                                <input type="text" name="qq" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">技术关键词</label>
                            <div class="layui-input-inline">
                                <input type="text" name="tip" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>



        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            {{#  if(d.user_id == 0){ }}
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add">上传文档</a>
            {{#  } else { }}

            {{#  } }}
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="check">审核</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
        </script>

    </div>
</div>
<script src="__ROOT__/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/bang/public/index.php/index/developer/get_check',

            cols: [[
                {field: 'num',  title: '编号', sort: true},
                {field: 'name',  title: '姓名'},
                {field: 'qq',  title: 'qq'},
                {field: 'tip',  title: '标签'},
                {field: 'uptime', title: '注册会员时间'},
                {title: '操作', minWidth: 150, toolbar: '#currentTableBar'}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 30,
            page: true
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */


        table.on('tool(currentTableFilter)', function (obj) {
            var mdata = obj.data;
            if (obj.event === 'check') {
                var index = layer.open({
                    title: '审核技术',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['40%', '60%'],
                    content: '/bang/public/index.php/index/developer/check_edit?id='+mdata.id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
            else if (obj.event === 'delete') {
                layer.confirm('真的要删除吗', function (index) {
                    var url = "{:url('developer/check_del')}";
                    var data={'id':mdata.id};
                    var success = "{:url('developer/check')}";
                    //    执行异步请求 ，$.post
                    $.post(url,data,function(result){
                        if(result.status ==0){
                            layer.open({
                                content:result.message,
                                icon:2,
                                title : '错误提示'
                            });

                        }
                        if(result.status ==1){
                            layer.open({
                                content : result.message,
                                icon : 1,
                                yes : function(){
                                    location.href=success;
                                }
                            });

                        }
                    },'JSON');
                    return false;

                });
            }

        });

    });
</script>

</body>
</html>